// import request from '@/server/instanceAxios.ts'
import {
    post,
    get
} from '@/server/request.ts'
import {
    BASE_URL
} from "@/utils/utils";

export function getInstanceOpinion(params) {
    return get({
        url: 'formTask/instance/getInstanceOpinion',
        params
    })
}
export function getTableHeader(data) {
    const {
        title
    } = data
    if (title.includes('政府专项')) {
        if (title.includes('2021')) {
            data.tableId = 23
        } else {
            data.tableId = 17
        }
    } else if (title.includes('区级')) {
        data.tableId = 22
    }
    return post({
        url: 'adminAnalysis/query/header',
        data
    })
}
export function findByEnterId(data) {
    return post({
        url: 'adjustBudget/findByEnterId',
        data
    })
}

export function findByFormGuid(data) {
    const {
        title
    } = data
    if (title.includes('2021')) {
        if (title.includes('政府专项')) {
            return findByFormGuidZF2021(data)
        }
        return findByFormGuid2021(data)
    } else {
        if (title.includes('政府专项')) {
            return findByFormGuidZF(data)
        }
        return findByFormGuid1(data)
    }
}
//政府专项
export function findByFormGuidZF2021(data) {
    return post({
        url: 'adjustSpecific/year/findByFormGuid',
        data
    })
}
export function findByFormGuidZF(data) {
    return post({
        url: 'adjustSpecific/findByFormGuid',
        data
    })
}
export function findByFormGuid1(data) {
    return post({
        url: 'adjustBudget/findByFormGuid',
        data
    })
}
export function findByFormGuid2021(data) {
    return post({
        url: 'adjustBudget/year/findByFormGuid',
        data
    })
}
export function getCanBackHistoryNodes(data) {
    return post({
        url: 'formTask/task/getCanBackHistoryNodes',
        data
    })
}
export function doAction(data) {
    return post({
        url: 'formTask/doAction',
        data
    })
}
export function status(data) {
    return post({
        url: 'adjustSpecific/status',
        data
    })
}
export function handleNodeFreeSelectUser(data) {
    return post({
        url: 'formTask/task/handleNodeFreeSelectUser',
        data
    })
}
export function filePage(data) {
    return post({
        url: 'file/page',
        data
    })
}
export function dynamicQueryHeader(data) {
    return post({
        url: 'dynamic/query/header',
        data
    })
}
export function budgetFindByFormGuid(data) {
    return post({
        url: 'budget/findByFormGuid',
        data
    })
}

//获取流程图
export function flowImage(params) {
    return get({
        url: '/formTask/instance/flowImage',
        params,
        responseType: "blob", // 返回格式，默认json，可选arraybuffer、blob、document、json、text、stream
    })
}


//预览文件
export function fileView({id}) {
   const fileViewUrl = `${BASE_URL}/onlinePreview?fileId=${id}`;
   window.open(fileViewUrl);

}